import java.util.Arrays;

public class Solution1824 {
    public int minSideJumps(int[] obstacles) {
        int[][] f=new int[obstacles.length][4];
        for (int[] ints : f) {
            Arrays.fill(ints,Integer.MAX_VALUE/3);
        }
        f[0][2]=0;
        f[0][1]=f[0][3]=1;
        for (int i = 1; i <= 3; i++) {
            if (obstacles[1]==i){
                f[1][i]=Integer.MAX_VALUE/3;
            }else {
                f[1][i]=f[0][i];
            }
        }
        for (int i=1;i<obstacles.length;i++){
            f[i][obstacles[i]]=Integer.MAX_VALUE/3;
            for (int j = 1; j <= 3; j++) {
                if (obstacles[i]==j){
                    f[i][j]=Integer.MAX_VALUE/3;
                }else {
                    for (int k = 1; k <= 3; k++) {
                        f[i][j]=Math.min(f[i][j],f[i][k]+1);
                    }
                    if (i<obstacles.length-1 && obstacles[i+1]!=j){
                        f[i+1][j]=f[i][j];
                    }
                }
            }
        }
        int min=Integer.MAX_VALUE;
        for (int i = 1; i <= 3; i++) {
            min=Math.min(min,f[obstacles.length-1][i]);
        }
        return min;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1824().minSideJumps(new int[]{0,1,1,3,3,0}));
    }
}
